home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / demo / wemdemo4.zip / INFO / LEMACS.10 (.txt) < prev    next >
GNU Info File  |  1994-09-21  |  47KB  |  804 lines

  1. This is Info file ../info/lemacs, produced by Makeinfo-1.55 from the
  2. input file lemacs.txi.
  3.    This file documents the GNU Emacs editor.
  4.    Copyright (C) 1985, 1986, 1988 Richard M. Stallman.  Copyright (C)
  5. 1991, 1992 Lucid, Inc.
  6.    Permission is granted to make and distribute verbatim copies of this
  7. manual provided the copyright notice and this permission notice are
  8. preserved on all copies.
  9.    Permission is granted to copy and distribute modified versions of
  10. this manual under the conditions for verbatim copying, provided also
  11. that the sections entitled "The GNU Manifesto", "Distribution" and "GNU
  12. General Public License" are included exactly as in the original, and
  13. provided that the entire resulting derived work is distributed under the
  14. terms of a permission notice identical to this one.
  15.    Permission is granted to copy and distribute translations of this
  16. manual into another language, under the above conditions for modified
  17. versions, except that the sections entitled "The GNU Manifesto",
  18. "Distribution" and "GNU General Public License" may be included in a
  19. translation approved by the author instead of in the original English.
  20. File: lemacs,  Node: Loading,  Next: Compiling Libraries,  Prev: Lisp Libraries,  Up: Lisp Libraries
  21. Loading Libraries
  22. -----------------
  23. `M-x load-file FILE'
  24.      Load the file FILE of Lisp code.
  25. `M-x load-library LIBRARY'
  26.      Load the library named LIBRARY.
  27. `M-x locate-library LIBRARY &optional NOSUFFIX'
  28.      Show the full path name of Emacs library `library'.
  29.    To execute a file of Emacs Lisp, use `M-x load-file'.  This command
  30. reads the file name you provide in the minibuffer, then executes the
  31. contents of that file as Lisp code.  It is not necessary to visit the
  32. file first; in fact, this command reads the file as found on disk, not
  33. the text in an Emacs buffer.
  34.    Once a file of Lisp code is installed in the Emacs Lisp library
  35. directories, users can load it using `M-x load-library'.  Programs can
  36. load it by calling `load-library', or with `load', a more primitive
  37. function that is similar but accepts some additional arguments.
  38.    `M-x load-library' differs from `M-x load-file' in that it searches
  39. a sequence of directories and tries three file names in each directory.
  40. The three names are: first, the specified name with `.elc' appended;
  41. second, the name with `.el' appended; third, the specified name alone.
  42. A `.elc' file would be the result of compiling the Lisp file into byte
  43. code;  if possible, it is loaded in preference to the Lisp file itself
  44. because the compiled file loads and runs faster.
  45.    Because the argument to `load-library' is usually not in itself a
  46. valid file name, file name completion is not available.  In fact, when
  47. using this command, you usually do not know exactly what file name will
  48. be used.
  49.    The sequence of directories searched by `M-x load-library' is
  50. specified by the variable `load-path', a list of strings that are
  51. directory names.  The elements of this list may not begin with "`~'",
  52. so you must call `expand-file-name' on them before adding them to the
  53. list.  The default value of the list contains the directory where the
  54. Lisp code for Emacs itself is stored.  If you have libraries of your
  55. own, put them in a single directory and add that directory to
  56. `load-path'.  `nil' in this list stands for the current default
  57. directory, but it is probably not a good idea to put `nil' in the list.
  58. If you start wishing that `nil' were in the list, you should probably
  59. use `M-x load-file' for this case.
  60.    The variable is initialized by the EMACSLOADPATH environment
  61. variable. If no value is specified, the variable takes the default value
  62. specified in the file `paths.h' when Emacs was built. If a path isn't
  63. specified in `paths.h', a default value is obtained from the file
  64. system, near the directory in which the Emacs executable resides.
  65.    `M-x locate-library' searches the directories in `load-path' like
  66. `M-x load-library' to find the file that `M-x load-library' would load.
  67. If the optional second argument NOSUFFIX is non-`nil', the suffixes
  68. `.elc' or `.el' are not added to the specified name LIBRARY (a la
  69. calling load instead of load-library).
  70.    You often do not have to give any command to load a library, because
  71. the commands defined in the library are set up to "autoload" that
  72. library.  Running any of those commands causes `load' to be called to
  73. load the library; this replaces the autoload definitions with the real
  74. ones from the library.
  75.    If autoloading a file does not finish, either because of an error or
  76. because of a `C-g' quit, all function definitions made by the file are
  77. undone automatically.  So are any calls to `provide'.  As a
  78. consequence, the entire file is loaded a second time if you use one of
  79. the autoloadable commands again.  This prevents problems when the
  80. command is no longer autoloading but works incorrectly because the file
  81. was only partially loaded.  Function definitions are undone only for
  82. autoloading; explicit calls to `load' do not undo anything if loading
  83. is not completed.
  84.    The variable `after-load-alist' takes an alist of expressions to be
  85. evalled when particular files are loaded.  Each element looks like
  86. `(FILENAME forms...)'.  When load is run and the filename argument is
  87. FILENAME, the forms in the corresponding element are executed at the
  88. end of loading.
  89.    FILENAME must match exactly.  Normally FILENAME is the name of a
  90. library, with no directory specified, since that is how load is
  91. normally called.  An error in `forms' does not undo the load, but does
  92. prevent execution of the rest of the `forms'.
  93. File: lemacs,  Node: Compiling Libraries,  Next: Mocklisp,  Prev: Loading,  Up: Lisp Libraries
  94. Compiling Libraries
  95. -------------------
  96.    Emacs Lisp code can be compiled into byte-code which loads faster,
  97. takes up less space when loaded, and executes faster.
  98. `M-x batch-byte-compile'
  99.      Run byte-compile-file on the files remaining on the command line.
  100. `M-x byte-compile-buffer &optional BUFFER'
  101.      Byte-compile and evaluate contents of BUFFER (default is current
  102.      buffer).
  103. `M-x byte-compile-file'
  104.      Compile a file of Lisp code named FILENAME into a file of byte
  105.      code.
  106. `M-x byte-compile-and-load-file FILENAME'
  107.      Compile a file of Lisp code named FILENAME into a file of byte
  108.      code and load it.
  109. `M-x byte-recompile-directory DIRECTORY'
  110.      Recompile every `.el' file in DIRECTORY that needs recompilation.
  111. `M-x disassemble'
  112.      Print disassembled code for OBJECT on (optional) STREAM.
  113. `M-x make-obsolete FUNCTION NEW'
  114.      Make the byte-compiler warn that FUNCTION is obsolete and NEW
  115.      should be used instead.
  116.    `byte-compile-file' creates a byte-code compiled file from an
  117. Emacs-Lisp source file.  The default argument for this function is the
  118. file visited in the current buffer.  The function reads the specified
  119. file, compiles it into byte code, and writes an output file whose name
  120. is made by appending `c' to the input file name.  Thus, the file
  121. `rmail.el' would be compiled into `rmail.elc'. To compile a file of
  122. Lisp code named FILENAME into a file of byte code and then load it, use
  123. `byte-compile-and-load-file'. To compile and evaluate Lisp code in a
  124. given buffer, use `byte-compile-buffer'.
  125.    To recompile all changed Lisp files in a directory, use `M-x
  126. byte-recompile-directory'.  Specify just the directory name as an
  127. argument.  Each `.el' file that has been byte-compiled before is
  128. byte-compiled again if it has changed since the previous compilation.
  129. A numeric argument to this command tells it to offer to compile each
  130. `.el' file that has not been compiled yet.  You must answer `y' or `n'
  131. to each offer.
  132.    You can use the function `batch-byte-compile' to invoke Emacs
  133. non-interactively from the shell to do byte compilation.  When you use
  134. this function, the files to be compiled are specified with command-line
  135. arguments.  Use a shell command of the form
  136.      emacs -batch -f batch-byte-compile FILES...
  137.    Directory names may also be given as arguments; in that case,
  138. `byte-recompile-directory' is invoked on each such directory.
  139. `batch-byte-compile' uses all remaining command-line arguments as file
  140. or directory names, then kills the Emacs process.
  141.    `M-x disassemble' explains the result of byte compilation.  Its
  142. argument is a function name.  It displays the byte-compiled code in a
  143. help window in symbolic form, one instruction per line.  If the
  144. instruction refers to a variable or constant, that is shown too.
  145. File: lemacs,  Node: Mocklisp,  Prev: Compiling Libraries,  Up: Lisp Libraries
  146. Converting Mocklisp to Lisp
  147. ---------------------------
  148.    GNU Emacs can run Mocklisp files by converting them to Emacs Lisp
  149. first.  To convert a Mocklisp file, visit it and then type `M-x
  150. convert-mocklisp-buffer'.  Then save the resulting buffer of Lisp file
  151. in a file whose name ends in `.el' and use the new file as a Lisp
  152. library.
  153.    You cannot currently byte-compile converted Mocklisp code.  The
  154. reason is that converted Mocklisp code uses some special Lisp features
  155. to deal with Mocklisp's incompatible ideas of how arguments are
  156. evaluated and which values signify "true" or "false".
  157. File: lemacs,  Node: Lisp Eval,  Next: Lisp Debug,  Prev: Lisp Libraries,  Up: Running
  158. Evaluating Emacs-Lisp Expressions
  159. =================================
  160.    Lisp programs intended to be run in Emacs should be edited in
  161. Emacs-Lisp mode; this will happen automatically for file names ending in
  162. `.el'.  By contrast, Lisp mode itself should be used for editing Lisp
  163. programs intended for other Lisp systems.  Emacs-Lisp mode can be
  164. selected with the command `M-x emacs-lisp-mode'.
  165.    For testing of Lisp programs to run in Emacs, it is useful to be able
  166. to evaluate part of the program as it is found in the Emacs buffer.  For
  167. example, if you change the text of a Lisp function definition, and then
  168. evaluate the definition, Emacs installs the change for future calls to
  169. the function.  Evaluation of Lisp expressions is also useful in any
  170. kind of editing task for invoking non-interactive functions (functions
  171. that are not commands).
  172. `M-ESC'
  173.      Read a Lisp expression in the minibuffer, evaluate it, and print
  174.      the value in the minibuffer (`eval-expression').
  175. `C-x C-e'
  176.      Evaluate the Lisp expression before point, and print the value in
  177.      the minibuffer (`eval-last-sexp').
  178. `C-M-x'
  179.      Evaluate the defun containing point or after point, and print the
  180.      value in the minibuffer (`eval-defun').
  181. `M-x eval-region'
  182.      Evaluate all the Lisp expressions in the region.
  183. `M-x eval-current-buffer'
  184.      Evaluate all the Lisp expressions in the buffer.
  185.    `M-ESC' (`eval-expression') is the most basic command for evaluating
  186. a Lisp expression interactively.  It reads the expression using the
  187. minibuffer, so you can execute any expression on a buffer regardless of
  188. what the buffer contains.  When evaluation is complete, the current
  189. buffer is once again the buffer that was current when `M-ESC' was typed.
  190.    `M-ESC' can easily confuse users, especially on keyboards with
  191. autorepeat where it can result from holding down the ESC key for too
  192. long.  Therefore, `eval-expression' is normally a disabled command.
  193. Attempting to use this command asks for confirmation and gives you the
  194. option of enabling it; once you enable the command, you are no longer
  195. required to confirm.  *Note Disabling::.
  196.    In Emacs-Lisp mode, the key `C-M-x' is bound to the function
  197. `eval-defun', which parses the defun containing point or following point
  198. as a Lisp expression and evaluates it.  The value is printed in the echo
  199. area.  This command is convenient for installing in the Lisp environment
  200. changes that you have just made in the text of a function definition.
  201.    The command `C-x C-e' (`eval-last-sexp') performs a similar job but
  202. is available in all major modes, not just Emacs-Lisp mode.  It finds
  203. the sexp before point, reads it as a Lisp expression, evaluates it, and
  204. prints the value in the echo area.  It is sometimes useful to type in an
  205. expression and then, with point still after it, type `C-x C-e'.
  206.    If `C-M-x' or `C-x C-e' are given a numeric argument, they print the
  207. value by inserting it into the current buffer at point, rather than in
  208. the echo area.  The argument value does not matter.
  209.    The most general command for evaluating Lisp expressions from a
  210. buffer is `eval-region'.  `M-x eval-region' parses the text of the
  211. region as one or more Lisp expressions, evaluating them one by one.
  212. `M-x eval-current-buffer' is similar but evaluates the entire buffer.
  213. This is a reasonable way to install the contents of a file of Lisp code
  214. that you are just ready to test.  After finding and fixing a bug, use
  215. `C-M-x' on each function that you change, to keep the Lisp world in
  216. step with the source file.
  217. File: lemacs,  Node: Lisp Debug,  Next: Lisp Interaction,  Prev: Lisp Eval,  Up: Running
  218. The Emacs-Lisp Debugger
  219. =======================
  220.    GNU Emacs contains a debugger for Lisp programs executing inside it.
  221. This debugger is normally not used; many commands frequently get Lisp
  222. errors when invoked in inappropriate contexts (such as `C-f' at the end
  223. of the buffer) and it would be unpleasant to enter a special debugging
  224. mode in this case.  When you want to make Lisp errors invoke the
  225. debugger, you must set the variable `debug-on-error' to non-`nil'.
  226. Quitting with `C-g' is not considered an error, and `debug-on-error'
  227. has no effect on the handling of `C-g'.  However, if you set
  228. `debug-on-quit' non-`nil', `C-g' will invoke the debugger.  This can be
  229. useful for debugging an infinite loop; type `C-g' once the loop has had
  230. time to reach its steady state.  `debug-on-quit' has no effect on
  231. errors.
  232.    You can make Emacs enter the debugger when a specified function is
  233. called, or at a particular place in Lisp code.  Use `M-x
  234. debug-on-entry' with argument FUN-NAME to have Emacs enter the debugger
  235. as soon as FUN-NAME is called.Use `M-x cancel-debug-on-entry' to make
  236. the function stop entering the debugger when called.  (Redefining the
  237. function also does this.)  To enter the debugger from some other place
  238. in Lisp code, you must insert the expression `(debug)' there and
  239. install the changed code with `C-M-x'.  *Note Lisp Eval::.
  240.    When the debugger is entered, it displays the previously selected
  241. buffer in one window and a buffer named `*Backtrace*' in another
  242. window.  The backtrace buffer contains one line for each level of Lisp
  243. function execution currently going on.  At the beginning of the buffer
  244. is a message describing the reason that the debugger was invoked, for
  245. example, an error message if it was invoked due to an error.
  246.    The backtrace buffer is read-only, and is in Backtrace mode, a
  247. special major mode in which letters are defined as debugger commands.
  248. The usual Emacs editing commands are available; you can switch windows
  249. to examine the buffer that was being edited at the time of the error,
  250. and you can switch buffers, visit files, and perform any other editing
  251. operations.  However, the debugger is a recursive editing level (*note
  252. Recursive Edit::.); it is a good idea to return to the backtrace buffer
  253. and explictly exit the debugger when you don't want to use it any more.
  254. Exiting the debugger kills the backtrace buffer.
  255.    The contents of the backtrace buffer show you the functions that are
  256. executing and the arguments that were given to them.  It also allows you
  257. to specify a stack frame by moving point to the line describing that
  258. frame.  The frame whose line point is on is considered the "current
  259. frame".  Some of the debugger commands operate on the current frame.
  260. Debugger commands are mainly used for stepping through code one
  261. expression at a time.  Here is a list of them:
  262.      Exit the debugger and continue execution.  In most cases,
  263.      execution of the program continues as if the debugger had never
  264.      been entered (aside from the effect of any variables or data
  265.      structures you may have changed while inside the debugger).  This
  266.      includes entry to the debugger due to function entry or exit,
  267.      explicit invocation, and quitting or certain errors.  Most errors
  268.      cannot be continued; trying to continue an error usually causes
  269.      the same error to occur again.
  270.      Continue execution, but enter the debugger the next time a Lisp
  271.      function is called.  This allows you to step through the
  272.      subexpressions of an expression, and see what the subexpressions
  273.      do and what values they compute.
  274.      When you enter the debugger this way, Emacs flags the stack frame
  275.      for the function call from which you entered.  The same function
  276.      is then called when you exit the frame.  To cancel this flag, use
  277.      `u'.
  278.      Set up to enter the debugger when the current frame is exited.
  279.      Frames that invoke the debugger on exit are flagged with stars.
  280.      Don't enter the debugger when the current frame is exited.  This
  281.      cancels a `b' command on a frame.
  282.      Read a Lisp expression in the minibuffer, evaluate it, and print
  283.      the value in the echo area.  This is equivalent to the command
  284.      `M-ESC', except that `e' is not normally disabled like `M-ESC'.
  285.      Terminate the program being debugged; return to top-level Emacs
  286.      command execution.
  287.      If the debugger was entered due to a `C-g' but you really want to
  288.      quit, not to debug, use the `q' command.
  289.      Return a value from the debugger.  The value is computed by
  290.      reading an expression with the minibuffer and evaluating it.
  291.      The value returned by the debugger makes a difference when the
  292.      debugger was invoked due to exit from a Lisp call frame (as
  293.      requested with `b'); then the value specified in the `r' command
  294.      is used as the value of that frame.
  295.      The debugger's return value also matters with many errors.  For
  296.      example, `wrong-type-argument' errors will use the debugger's
  297.      return value instead of the invalid argument; `no-catch' errors
  298.      will use the debugger value as a throw tag instead of the tag that
  299.      was not found.  If an error was signaled by calling the Lisp
  300.      function `signal', the debugger's return value is returned as the
  301.      value of `signal'.
  302. File: lemacs,  Node: Lisp Interaction,  Next: External Lisp,  Prev: Lisp Debug,  Up: Running
  303. Lisp Interaction Buffers
  304. ========================
  305.    The buffer `*scratch*', which is selected when Emacs starts up, is
  306. provided for evaluating Lisp expressions interactively inside Emacs.
  307. Both the expressions you evaluate and their output goes in the buffer.
  308.    The `*scratch*' buffer's major mode is Lisp Interaction mode, which
  309. is the same as Emacs-Lisp mode except for one command, LFD.  In
  310. Emacs-Lisp mode, LFD is an indentation command.  In Lisp Interaction
  311. mode, LFD is bound to `eval-print-last-sexp'.  This function reads the
  312. Lisp expression before point, evaluates it, and inserts the value in
  313. printed representation before point.
  314.    The way to use the `*scratch*' buffer is to insert Lisp expressions
  315. at the end, ending each one with LFD so that it will be evaluated.  The
  316. result is a complete typescript of the expressions you have evaluated
  317. and their values.
  318.    The rationale for this feature is that Emacs must have a buffer when
  319. it starts up, but that buffer is not useful for editing files since a
  320. new buffer is made for every file that you visit.  The Lisp interpreter
  321. typescript is the most useful thing I can think of for the initial
  322. buffer to do.  `M-x lisp-interaction-mode' will put any buffer in Lisp
  323. Interaction mode.
  324. File: lemacs,  Node: External Lisp,  Prev: Lisp Interaction,  Up: Running
  325. Running an External Lisp
  326. ========================
  327.    Emacs has facilities for running programs in other Lisp systems.
  328. You can run a Lisp process as an inferior of Emacs, and pass
  329. expressions to it to be evaluated.  You can also pass changed function
  330. definitions directly from the Emacs buffers in which you edit the Lisp
  331. programs to the inferior Lisp process.
  332.    To run an inferior Lisp process, type `M-x run-lisp'.  This runs the
  333. program named `lisp', the same program you would run by typing `lisp'
  334. as a shell command, with both input and output going through an Emacs
  335. buffer named `*lisp*'.  In other words, any "terminal output" from Lisp
  336. will go into the buffer, advancing point, and any "terminal input" for
  337. Lisp comes from text in the buffer.  To give input to Lisp, go to the
  338. end of the buffer and type the input, terminated by RET.  The `*lisp*'
  339. buffer is in Inferior Lisp mode, which has all the special
  340. characteristics of Lisp mode and Shell mode (*note Shell Mode::.).
  341.    Use Lisp mode to run the source files of programs in external Lisps.
  342. You can select this mode with `M-x lisp-mode'.  It is used automatically
  343. for files whose names end in `.l' or `.lisp', as most Lisp systems
  344. usually expect.
  345.    When you edit a function in a Lisp program you are running, the
  346. easiest way to send the changed definition to the inferior Lisp process
  347. is the key `C-M-x'.  In Lisp mode, this key runs the function
  348. `lisp-send-defun', which finds the defun around or following point and
  349. sends it as input to the Lisp process.  (Emacs can send input to any
  350. inferior process regardless of what buffer is current.)
  351.    Contrast the meanings of `C-M-x' in Lisp mode (for editing programs
  352. to be run in another Lisp system) and Emacs-Lisp mode (for editing Lisp
  353. programs to be run in Emacs): in both modes it has the effect of
  354. installing the function definition that point is in, but the way of
  355. doing so is different according to where the relevant Lisp environment
  356. is found.  *Note Lisp Modes::.
  357. File: lemacs,  Node: Abbrevs,  Next: Picture,  Prev: Running,  Up: Top
  358. Abbrevs
  359. *******
  360.    An "abbrev" is a word which "expands", if you insert it, into some
  361. different text.  Abbrevs are defined by the user to expand in specific
  362. ways.  For example, you might define `foo' as an abbrev expanding to
  363. `find outer otter'.  With this abbrev defined, you would be able to get
  364. `find outer otter ' into the buffer by typing `f o o SPC'.
  365.    Abbrevs expand only when Abbrev mode (a minor mode) is enabled.
  366. Disabling Abbrev mode does not cause abbrev definitions to be discarded,
  367. but they do not expand until Abbrev mode is enabled again.  The command
  368. `M-x abbrev-mode' toggles Abbrev mode; with a numeric argument, it
  369. turns Abbrev mode on if the argument is positive, off otherwise.  *Note
  370. Minor Modes::.  `abbrev-mode' is also a variable; Abbrev mode is on
  371. when the variable is non-`nil'.  The variable `abbrev-mode'
  372. automatically becomes local to the current buffer when it is set.
  373.    Abbrev definitions can be "mode-specific"--active only in one major
  374. mode.  Abbrevs can also have "global" definitions that are active in
  375. all major modes.  The same abbrev can have a global definition and
  376. various mode-specific definitions for different major modes.  A mode
  377. specific definition for the current major mode overrides a global
  378. definition.
  379.    You can define Abbrevs interactively during an editing session.  You
  380. can also save lists of abbrev definitions in files and reload them in
  381. later sessions.  Some users keep extensive lists of abbrevs that they
  382. load in every session.
  383.    A second kind of abbreviation facility is called the "dynamic
  384. expansion".  Dynamic abbrev expansion happens only when you give an
  385. explicit command and the result of the expansion depends only on the
  386. current contents of the buffer.  *Note Dynamic Abbrevs::.
  387. * Menu:
  388. * Defining Abbrevs::  Defining an abbrev, so it will expand when typed.
  389. * Expanding Abbrevs:: Controlling expansion: prefixes, canceling expansion.
  390. * Editing Abbrevs::   Viewing or editing the entire list of defined abbrevs.
  391. * Saving Abbrevs::    Saving the entire list of abbrevs for another session.
  392. * Dynamic Abbrevs::   Abbreviations for words already in the buffer.
  393. File: lemacs,  Node: Defining Abbrevs,  Next: Expanding Abbrevs,  Prev: Abbrevs,  Up: Abbrevs
  394. Defining Abbrevs
  395. ================
  396. `C-x +'
  397.      Define an abbrev to expand into some text before point
  398.      (`add-global-abbrev').
  399. `C-x C-a'
  400.      Similar, but define an abbrev available only in the current major
  401.      mode (`add-mode-abbrev').
  402. `C-x -'
  403.      Define a word in the buffer as an abbrev
  404.      (`inverse-add-global-abbrev').
  405. `C-x C-h'
  406.      Define a word in the buffer as a mode-specific abbrev
  407.      (`inverse-add-mode-abbrev').
  408. `M-x kill-all-abbrevs'
  409.      After this command, no abbrev definitions remain in effect.
  410.    The usual way to define an abbrev is to enter the text you want the
  411. abbrev to expand to, position point after it, and type `C-x +'
  412. (`add-global-abbrev').  This reads the abbrev itself using the
  413. minibuffer, and then defines it as an abbrev for one or more words
  414. before point.  Use a numeric argument to say how many words before point
  415. should be taken as the expansion.  For example, to define the abbrev
  416. `foo' as in the example above, insert the text `find outer otter', then
  417. `C-u 3 C-x + f o o RET'.
  418.    An argument of zero to `C-x +' means to use the contents of the
  419. region as the expansion of the abbrev being defined.
  420.    The command `C-x C-a' (`add-mode-abbrev') is similar, but defines a
  421. mode-specific abbrev.  Mode specific abbrevs are active only in a
  422. particular major mode.  `C-x C-a' defines an abbrev for the major mode
  423. in effect at the time `C-x C-a' is typed.  The arguments work the same
  424. way they do for `C-x +'.
  425.    If the text of an abbrev you want is already in the buffer instead of
  426. the expansion, use command `C-x -' (`inverse-add-global-abbrev')
  427. instead of `C-x +', or use `C-x C-h' (`inverse-add-mode-abbrev')
  428. instead of `C-x C-a'.  These commands are called "inverse" because they
  429. invert the meaning of the argument found in the buffer and the argument
  430. read using the minibuffer.
  431.    To change the definition of an abbrev, just add the new definition.
  432. You will be asked to confirm if the abbrev has a prior definition.  To
  433. remove an abbrev definition, give a negative argument to `C-x +' or `C-x
  434. C-a'.  You must choose the command to specify whether to kill a global
  435. definition or a mode-specific definition for the current mode, since
  436. those two definitions are independent for one abbrev.
  437.    `M-x kill-all-abbrevs' removes all existing abbrev definitions.
  438. File: lemacs,  Node: Expanding Abbrevs,  Next: Editing Abbrevs,  Prev: Defining Abbrevs,  Up: Abbrevs
  439. Controlling Abbrev Expansion
  440. ============================
  441.    An abbrev expands whenever it is in a buffer just before point and
  442. you type and a self-inserting punctuation character (SPC, comma, etc.).
  443. Most often an abbrev is used by inserting the abbrev followed by
  444. punctuation.
  445.    Abbrev expansion preserves case; thus, `foo' expands into `find
  446. outer otter'; `Foo' into `Find outer otter', and `FOO' into `FIND OUTER
  447. OTTER' or `Find Outer Otter' according to the variable
  448. `abbrev-all-caps' (a non-`nil' value chooses the first of the two
  449. expansions).
  450.    Two commands are available to control abbrev expansion:
  451. `M-''
  452.      Separate a prefix from a following abbrev to be expanded
  453.      (`abbrev-prefix-mark').
  454. `C-x ''
  455.      Expand the abbrev before point (`expand-abbrev').  This is
  456.      effective even when Abbrev mode is not enabled.
  457. `M-x unexpand-abbrev'
  458.      Undo last abbrev expansion.
  459. `M-x expand-region-abbrevs'
  460.      Expand some or all abbrevs found in the region.
  461.    You may wish to expand an abbrev with a prefix attached.  For
  462. example, if `cnst' expands into `construction', you may want to use it
  463. to enter `reconstruction'.  It does not work to type `recnst', because
  464. that is not necessarily a defined abbrev.  Instead, you can use the
  465. command `M-'' (`abbrev-prefix-mark') between the prefix `re' and the
  466. abbrev `cnst'.  First, insert `re'.  Then type `M-''; this inserts a
  467. minus sign in the buffer to indicate that it has done its work.  Then
  468. insert the abbrev `cnst'.  The buffer now contains `re-cnst'.  Now
  469. insert a punctuation character to expand the abbrev `cnst' into
  470. `construction'.  The minus sign is deleted at this point, by `M-''.
  471. The resulting text is the desired `reconstruction'.
  472.    If you actually want the text of the abbrev in the buffer, rather
  473. than its expansion, insert the following punctuation with `C-q'.  Thus,
  474. `foo C-q -' leaves `foo-' in the buffer.
  475.    If you expand an abbrev by mistake, you can undo the expansion
  476. (replace the expansion by the original abbrev text) with `M-x
  477. unexpand-abbrev'.  You can also use `C-_' (`undo') to undo the
  478. expansion; but that will first undo the insertion of the punctuation
  479. character.
  480.    `M-x expand-region-abbrevs' searches through the region for defined
  481. abbrevs, and  offers to replace each one it finds with its expansion.
  482. This command is useful if you have typed text using abbrevs but forgot
  483. to turn on Abbrev mode first.  It may also be useful together with a
  484. special set of abbrev definitions for making several global
  485. replacements at once.  The command is effective even if Abbrev mode is
  486. not enabled.
  487. File: lemacs,  Node: Editing Abbrevs,  Next: Saving Abbrevs,  Prev: Expanding Abbrevs,  Up: Abbrevs
  488. Examining and Editing Abbrevs
  489. =============================
  490. `M-x list-abbrevs'
  491.      Print a list of all abbrev definitions.
  492. `M-x edit-abbrevs'
  493.      Edit a list of abbrevs; you can add, alter or remove definitions.
  494.    The output from `M-x list-abbrevs' looks like this:
  495.      (lisp-mode-abbrev-table)
  496.      "dk"           0    "define-key"
  497.      (global-abbrev-table)
  498.      "dfn"           0    "definition"
  499. (Some blank lines of no semantic significance, and some other abbrev
  500. tables, have been omitted.)
  501.    A line containing a name in parentheses is the header for abbrevs in
  502. a particular abbrev table; `global-abbrev-table' contains all the global
  503. abbrevs, and the other abbrev tables that are named after major modes
  504. contain the mode-specific abbrevs.
  505.    Within each abbrev table, each non-blank line defines one abbrev.
  506. The word at the beginning is the abbrev.  The number that appears is
  507. the number of times the abbrev has been expanded.  Emacs keeps track of
  508. this to help you see which abbrevs you actually use, in case you want
  509. to eliminate those that you don't use often.  The string at the end of
  510. the line is the expansion.
  511.    `M-x edit-abbrevs' allows you to add, change or kill abbrev
  512. definitions by editing a list of them in an Emacs buffer.  The list has
  513. the format described above.  The buffer of abbrevs is called
  514. `*Abbrevs*', and is in Edit-Abbrevs mode.  This mode redefines the key
  515. `C-c C-c' to install the abbrev definitions as specified in the buffer.
  516. The  `edit-abbrevs-redefine' command does this.  Any abbrevs not
  517. described in the buffer are eliminated when this is done.
  518.    `edit-abbrevs' is actually the same as `list-abbrevs' except that it
  519. selects the buffer `*Abbrevs*' whereas `list-abbrevs' merely displays
  520. it in another window.
  521. File: lemacs,  Node: Saving Abbrevs,  Next: Dynamic Abbrevs,  Prev: Editing Abbrevs,  Up: Abbrevs
  522. Saving Abbrevs
  523. ==============
  524.    These commands allow you to keep abbrev definitions between editing
  525. sessions.
  526. `M-x write-abbrev-file'
  527.      Write a file describing all defined abbrevs.
  528. `M-x read-abbrev-file'
  529.      Read such an abbrev file and define abbrevs as specified there.
  530. `M-x quietly-read-abbrev-file'
  531.      Similar, but do not display a message about what is going on.
  532. `M-x define-abbrevs'
  533.      Define abbrevs from buffer.
  534. `M-x insert-abbrevs'
  535.      Insert all abbrevs and their expansions into the buffer.
  536.    Use `M-x write-abbrev-file' to save abbrev definitions for use in a
  537. later session.  The command reads a file name using the minibuffer and
  538. writes a description of all current abbrev definitions into the
  539. specified file.  The text stored in the file looks like the output of
  540. `M-x list-abbrevs'.
  541.    `M-x read-abbrev-file' prompts for a file name using the minibuffer
  542. and reads the specified file, defining abbrevs according to its
  543. contents.  `M-x quietly-read-abbrev-file' is the same but does not
  544. display a message in the echo area; it is actually useful primarily in
  545. the `.emacs' file.  If you give an empty argument to either of these
  546. functions, the file name Emacs uses is the value of the variable
  547. `abbrev-file-name', which is by default `"~/.abbrev_defs"'.
  548.    Emacs offers to save abbrevs automatically if you have changed any of
  549. them, whenever it offers to save all files (for `C-x s' or `C-x C-c').
  550. Set the variable `save-abbrevs' to `nil' to inhibit this feature.
  551.    The commands `M-x insert-abbrevs' and `M-x define-abbrevs' are
  552. similar to the previous commands but work on text in an Emacs buffer.
  553. `M-x insert-abbrevs' inserts text into the current buffer before point,
  554. describing all current abbrev definitions; `M-x define-abbrevs' parses
  555. the entire current buffer and defines abbrevs accordingly.
  556. File: lemacs,  Node: Dynamic Abbrevs,  Prev: Saving Abbrevs,  Up: Abbrevs
  557. Dynamic Abbrev Expansion
  558. ========================
  559.    The abbrev facility described above operates automatically as you
  560. insert text, but all abbrevs must be defined explicitly.  By contrast,
  561. "dynamic abbrevs" allow the meanings of abbrevs to be determined
  562. automatically from the contents of the buffer, but dynamic abbrev
  563. expansion happens only when you request it explicitly.
  564. `M-/'
  565.      Expand the word in the buffer before point as a "dynamic abbrev",
  566.      by searching in the buffer for words starting with that
  567.      abbreviation (`dabbrev-expand').
  568.    For example, if the buffer contains `does this follow ' and you type
  569. `f o M-/', the effect is to insert `follow' because that is the last
  570. word in the buffer that starts with `fo'.  A numeric argument to `M-/'
  571. says to take the second, third, etc. distinct expansion found looking
  572. backward from point.  Repeating `M-/' searches for an alternative
  573. expansion by looking farther back.  After the entire buffer before
  574. point has been considered, the buffer after point is searched.
  575.    Dynamic abbrev expansion is completely independent of Abbrev mode;
  576. the expansion of a word with `M-/' is completely independent of whether
  577. it has a definition as an ordinary abbrev.
  578. File: lemacs,  Node: Picture,  Next: Sending Mail,  Prev: Abbrevs,  Up: Top
  579. Editing Pictures
  580. ****************
  581.    If you want to create a picture made out of text characters (for
  582. example, a picture of the division of a register into fields, as a
  583. comment in a program), use the command `edit-picture' to enter Picture
  584. mode.
  585.    In Picture mode, editing is based on the "quarter-plane" model of
  586. text.  In this model, the text characters lie studded on an area that
  587. stretches infinitely far to the right and downward.  The concept of the
  588. end of a line does not exist in this model; the most you can say is
  589. where the last non-blank character on the line is found.
  590.    Of course, Emacs really always considers text as a sequence of
  591. characters, and lines really do have ends.  But in Picture mode most
  592. frequently-used keys are rebound to commands that simulate the
  593. quarter-plane model of text.  They do this by inserting spaces or by
  594. converting tabs to spaces.
  595.    Most of the basic editing commands of Emacs are redefined by Picture
  596. mode to do essentially the same thing but in a quarter-plane way.  In
  597. addition, Picture mode defines various keys starting with the `C-c'
  598. prefix to run special picture editing commands.
  599.    One of these keys, `C-c C-c', is pretty important.  Often a picture
  600. is part of a larger file that is usually edited in some other major
  601. mode.  `M-x edit-picture' records the name of the previous major mode.
  602. You can then use the `C-c C-c' command (`picture-mode-exit') to restore
  603. that mode.  `C-c C-c' also deletes spaces from the ends of lines,
  604. unless you give it a numeric argument.
  605.    The commands used in Picture mode all work in other modes (provided
  606. the `picture' library is loaded), but are only  bound to keys in
  607. Picture mode.  Note that the descriptions below talk of moving "one
  608. column" and so on, but all the picture mode commands handle numeric
  609. arguments as their normal equivalents do.
  610.    Turning on Picture mode calls the value of the variable
  611. `picture-mode-hook' as a function, with no arguments, if that value
  612. exists and is non-`nil'.
  613. * Menu:
  614. * Basic Picture::         Basic concepts and simple commands of Picture Mode.
  615. * Insert in Picture::     Controlling direction of cursor motion
  616.                            after "self-inserting" characters.
  617. * Tabs in Picture::       Various features for tab stops and indentation.
  618. * Rectangles in Picture:: Clearing and superimposing rectangles.
  619. File: lemacs,  Node: Basic Picture,  Next: Insert in Picture,  Prev: Picture,  Up: Picture
  620. Basic Editing in Picture Mode
  621. =============================
  622.    Most keys do the same thing in Picture mode that they usually do,
  623. but do it in a quarter-plane style.  For example, `C-f' is rebound to
  624. run `picture-forward-column', which moves point one column to the
  625. right, by inserting a space if necessary, so that the actual end of the
  626. line makes no difference.  `C-b' is rebound to run
  627. `picture-backward-column', which always moves point left one column,
  628. converting a tab to multiple spaces if necessary.  `C-n' and `C-p' are
  629. rebound to run `picture-move-down' and `picture-move-up', which can
  630. either insert spaces or convert tabs as necessary to make sure that
  631. point stays in exactly the same column.  `C-e' runs
  632. `picture-end-of-line', which moves to after the last non-blank
  633. character on the line.  There was no need to change `C-a', as the choice
  634. of screen model does not affect beginnings of lines.
  635.    Insertion of text is adapted to the quarter-plane screen model
  636. through the use of Overwrite mode (*note Minor Modes::.).
  637. Self-inserting characters replace existing text, column by column,
  638. rather than pushing existing text to the right.  RET runs
  639. `picture-newline', which just moves to the beginning of the following
  640. line so that new text will replace that line.
  641.    Text is erased instead of deleted and killed.  DEL
  642. (`picture-backward-clear-column') replaces the preceding character with
  643. a space rather than removing it.  `C-d' (`picture-clear-column') does
  644. the same in a forward direction.  `C-k' (`picture-clear-line') really
  645. kills the contents of lines, but never removes the newlines from a
  646. buffer.
  647.    To do actual insertion, you must use special commands.  `C-o'
  648. (`picture-open-line') creates a blank line, but does so after the
  649. current line; it never splits a line.  `C-M-o', `split-line', makes
  650. sense in Picture mode, so it remains unchanged.  LFD
  651. (`picture-duplicate-line') inserts another line with the same contents
  652. below the current line.
  653.    To actually delete parts of the picture, use `C-w', or with `C-c
  654. C-d' (which is defined as `delete-char', as `C-d' is in other modes),
  655. or with one of the picture rectangle commands (*note Rectangles in
  656. Picture::.).
  657. File: lemacs,  Node: Insert in Picture,  Next: Tabs in Picture,  Prev: Basic Picture,  Up: Picture
  658. Controlling Motion after Insert
  659. ===============================
  660.    Since "self-inserting" characters just overwrite and move point in
  661. Picture mode, there is no essential restriction on how point should be
  662. moved.  Normally point moves right, but you can specify any of the eight
  663. orthogonal or diagonal directions for motion after a "self-inserting"
  664. character.  This is useful for drawing lines in the buffer.
  665. `C-c <'
  666.      Move left after insertion (`picture-movement-left').
  667. `C-c >'
  668.      Move right after insertion (`picture-movement-right').
  669. `C-c ^'
  670.      Move up after insertion (`picture-movement-up').
  671. `C-c .'
  672.      Move down after insertion (`picture-movement-down').
  673. `C-c `'
  674.      Move up and left ("northwest") after insertion
  675.      (`picture-movement-nw').
  676. `C-c ''
  677.      Move up and right ("northeast") after insertion
  678.      (`picture-movement-ne').
  679. `C-c /'
  680.      Move down and left ("southwest") after insertion
  681.      (`picture-movement-sw').
  682. `C-c \'
  683.      Move down and right ("southeast") after insertion
  684.      (`picture-movement-se').
  685.    Two motion commands move based on the current Picture insertion
  686. direction.  The command `C-c C-f' (`picture-motion') moves in the same
  687. direction as motion after "insertion" currently does, while `C-c C-b'
  688. (`picture-motion-reverse') moves in the opposite direction.
  689. File: lemacs,  Node: Tabs in Picture,  Next: Rectangles in Picture,  Prev: Insert in Picture,  Up: Picture
  690. Picture Mode Tabs
  691. =================
  692.    Two kinds of tab-like action are provided in Picture mode.
  693. Context-based tabbing is done with `M-TAB' (`picture-tab-search').
  694. With no argument, it moves to a point underneath the next "interesting"
  695. character that follows whitespace in the previous non-blank line.
  696. "Next" here means "appearing at a horizontal position greater than the
  697. one point starts out at".  With an argument, as in `C-u M-TAB', the
  698. command moves to the next such interesting character in the current
  699. line.  `M-TAB' does not change the text; it only moves point.
  700. "Interesting" characters are defined by the variable
  701. `picture-tab-chars', which contains a string of characters considered
  702. interesting.  Its default value is `"!-~"'.
  703.    TAB itself runs `picture-tab', which operates based on the current
  704. tab stop settings; it is the Picture mode equivalent of
  705. `tab-to-tab-stop'.  Without arguments it just moves point, but with a
  706. numeric argument it clears the text that it moves over.
  707.    The context-based and tab-stop-based forms of tabbing are brought
  708. together by the command `C-c TAB', `picture-set-tab-stops'.  This
  709. command sets the tab stops to the positions which `M-TAB' would
  710. consider significant in the current line.  If you use this command,
  711. together with TAB, you can get the effect of context-based tabbing.  But
  712. `M-TAB' is more convenient in the cases where it is sufficient.
  713. File: lemacs,  Node: Rectangles in Picture,  Prev: Tabs in Picture,  Up: Picture
  714. Picture Mode Rectangle Commands
  715. ===============================
  716.    Picture mode defines commands for working on rectangular pieces of
  717. the text in ways that fit with the quarter-plane model.  The standard
  718. rectangle commands may also be useful (*note Rectangles::.).
  719. `C-c C-k'
  720.      Clear out the region-rectangle (`picture-clear-rectangle').  With
  721.      argument, kill it.
  722. `C-c C-w R'
  723.      Similar but save rectangle contents in register R first
  724.      (`picture-clear-rectangle-to-register').
  725. `C-c C-y'
  726.      Copy last killed rectangle into the buffer by overwriting, with
  727.      upper left corner at point (`picture-yank-rectangle').  With
  728.      argument, insert instead.
  729. `C-c C-x R'
  730.      Similar, but use the rectangle in register R
  731.      (`picture-yank-rectangle-from-register').
  732.    The picture rectangle commands `C-c C-k' (`picture-clear-rectangle')
  733. and `C-c C-w' (`picture-clear-rectangle-to-register') differ from the
  734. standard rectangle commands in that they normally clear the rectangle
  735. instead of deleting it; this is analogous with the way `C-d' is changed
  736. in Picture mode.
  737.    However, deletion of rectangles can be useful in Picture mode, so
  738. these commands delete the rectangle if given a numeric argument.
  739.    The Picture mode commands for yanking rectangles differ from the
  740. standard ones in overwriting instead of inserting.  This is the same
  741. way that Picture mode insertion of other text is different from other
  742. modes.  `C-c C-y' (`picture-yank-rectangle') inserts (by overwriting)
  743. the rectangle that was most recently killed, while `C-c C-x'
  744. (`picture-yank-rectangle-from-register') does for the rectangle found
  745. in a specified register.
  746. File: lemacs,  Node: Sending Mail,  Next: Rmail,  Prev: Picture,  Up: Top
  747. Sending Mail
  748. ************
  749.    To send a message in Emacs, start by typing the command (`C-x m') to
  750. select and initialize the `*mail*' buffer.  You can then edit the text
  751. and headers of the message in the mail buffer, and type the command
  752. (`C-c C-c') to send the message.
  753. `C-x m'
  754.      Begin composing a message to send (`mail').
  755. `C-x 4 m'
  756.      Likewise, but display the message in another window
  757.      (`mail-other-window').
  758. `C-c C-c'
  759.      In Mail mode, send the message and switch to another buffer
  760.      (`mail-send-and-exit').
  761.    The command `C-x m' (`mail') selects a buffer named `*mail*' and
  762. initializes it with the skeleton of an outgoing message.  `C-x 4 m'
  763. (`mail-other-window') selects the `*mail*' buffer in a different
  764. window, leaving the previous current buffer visible.
  765.    Because the buffer for mail composition is an ordinary Emacs buffer,
  766. you can switch to other buffers while in the middle of composing mail,
  767. and switch back later (or never).  If you use the `C-x m' command again
  768. when you have been composing another message but have not sent it, a
  769. new mail buffer will be created; in this way, you can compose multiple
  770. messages at once.  You can switch back to and complete an unsent
  771. message by using the normal buffer selection mechanisms.
  772.    `C-u C-x m' is another way to switch back to a message in progress:
  773. it will search for an existing, unsent mail message buffer and select
  774. * Menu:
  775. * Format: Mail Format.    Format of the mail being composed.
  776. * Headers: Mail Headers.  Details of allowed mail header fields.
  777. * Mode: Mail Mode.        Special commands for editing mail being composed.
  778. File: lemacs,  Node: Mail Format,  Next: Mail Headers,  Prev: Sending Mail,  Up: Sending Mail
  779. The Format of the Mail Buffer
  780. =============================
  781.    In addition to the "text" or contents, a message has "header fields"
  782. which say who sent it, when, to whom, why, and so on.  Some header
  783. fields such as the date and sender are created automatically after the
  784. message is sent.  Others, such as the recipient names, must be
  785. specified by you in order to send the message properly.
  786.    Mail mode provides a few commands to help you edit some header
  787. fields, and some are preinitialized in the buffer automatically at
  788. times.  You can insert or edit any header fields using ordinary editing
  789. commands.
  790.    The line in the buffer that says
  791.      --text follows this line--
  792. is a special delimiter that separates the headers you have specified
  793. from the text.  Whatever follows this line is the text of the message;
  794. the headers precede it.  The delimiter line itself does not appear in
  795. the message actually sent.  The text used for the delimiter line is
  796. controlled by the variable `mail-header-separator'.
  797.    Here is an example of what the headers and text in the `*mail*'
  798. buffer might look like.
  799.      To: rms@mc
  800.      CC: mly@mc, rg@oz
  801.      Subject: The Emacs Manual
  802.      --Text follows this line--
  803.      Please ignore this message.
  804.